package st.business.tepth.business.history;

import java.util.ArrayList;
import java.util.List;

import st.business.tepth.business.bean.CommonBean;
import st.business.tepth.business.bean.HistoryConditionBean;
import st.business.tepth.config.ItemFields;
import st.shadow.library.ui.recycler.MultipleItemEntity;

/**
 * @author zhangyu
 * @date 2019/5/23
 */
public class HistoryDataConvert {
    public List<MultipleItemEntity> convertToConditions(HistoryConditionBean
                                                                historyConditionBean) {
        List<MultipleItemEntity> entityList = new ArrayList<>();
        if (historyConditionBean != null) {
            List<CommonBean> classification = historyConditionBean.getClassification();
            List<CommonBean> workType = historyConditionBean.getWorkType();
            entityList.add(MultipleItemEntity.builder().setItemType(HistorySearchKeyAdapter.TYPE_0)
                    .setField("name", "系别")
                    .build());
            if (classification != null) {
                for (CommonBean commonBean : classification) {
                    entityList.add(MultipleItemEntity.builder().
                            setItemType(HistorySearchKeyAdapter.TYPE_1)
                            .setField(ItemFields.ITEM_OBJ, commonBean)
                            .setField("checked", false)
                            .build());
                }
            }
            entityList.add(MultipleItemEntity.builder().
                    setItemType(HistorySearchKeyAdapter.TYPE_0)
                    .setField("name", "作业类型")
                    .build());
            if (workType != null) {
                for (CommonBean commonBean : workType)
                    entityList.add(MultipleItemEntity.builder().
                            setItemType(HistorySearchKeyAdapter.TYPE_2)
                            .setField("checked", false)
                            .setField(ItemFields.ITEM_OBJ, commonBean)
                            .build());
            }
        }
        return entityList;
    }
}
